<?php header('Content-type: text/javascript'); ?>

<?php 

$sc_array = array(
    'Leading Text'      => '[lead]\x00LEADING TEXT\x00[/lead]',
    'Highlight'         => '[highlight]\x00HIGHLIGHT\x00[/highlight]',
    'Horizontal ruler'  => '[hr style="solid|dash|dot"]',
    'Button'            => '[button url="url" style="xsmall|small|normal"]\x00BUTTON\x00[/button]',
    'Message'           => '[message type="success|error|info|notice"]\x00MESSAGE\x00[/message]',
    'Toggle'            => '[toggles]<br><br>[toggle title="title1" active="yes|no"]CONTENT1[/toggle]<br>[toggle title="title2" active="yes|no"]CONTENT2[/toggle]<br>[toggle title="title3" active="yes|no"]CONTENT3[/toggle]<br><br>[/toggles]',
    'Accordion'         => '[accordions]<br><br>[accordion title="title1" active="yes|no"]CONTENT1[/accordion]<br>[accordion title="title2" active="yes|no"]CONTENT2[/accordion]<br>[accordion title="title3" active="yes|no"]CONTENT3[/accordion]<br><br>[/accordions]',
    '1-column lightbox image'   => '[lightbox]<br><br>[1c_lightbox_image title="title" src="imageurl"]<br><br>[/lightbox]',
    '2-column lightbox image'   => '[lightbox]<br><br>[2c_lightbox_image title="title" src="imageurl" last="no"]<br>[2c_lightbox_image title="title" src="imageurl" last="yes"]<br><br>[/lightbox]',
    '3-column lightbox image'   => '[lightbox]<br><br>[3c_lightbox_image title="title" src="imageurl" last="no"]<br>[3c_lightbox_image title="title" src="imageurl" last="no"]<br>[3c_lightbox_image title="title" src="imageurl" last="yes"]<br><br>[/lightbox]',
    'Lightbox media'    => '[lightbox_media title="title" src="imageurl"]\x00MEDIA LINK\x00[/lightbox_media]',
    'Image Slider'      => '[img_slider]<br><br>[img_slide alt="alt" src="imageurl"]<br>[img_slide alt="alt" src="imageurl"]<br><br>[/img_slider]',
    'Quote Slider'      => '[quote_slider]<br><br>[quote_slide byline="quoteby"]QUOTE[/quote_slide]<br>[quote_slide byline="quoteby"]QUOTE[/quote_slide]<br><br>[/quote_slider]',
    'Columns'           => '[columns]<br><br>[column size="half|third|fourth|two-thirds|three-fourths" last="yes|no"]\x00CONTENT\x00[/column]<br><br>[/columns]',
    '2-column example'  => '[columns]<br><br>[column size="half" last="no"]CONTENT[/column]<br>[column size="half" last="yes"]CONTENT[/column]<br><br>[/columns]',
    '3-column example'  => '[columns]<br><br>[column size="third" last="no"]CONTENT[/column]<br>[column size="third" last="no"]CONTENT[/column]<br>[column size="third" last="yes"]CONTENT[/column]<br><br>[/columns]',
    '4-column example'  => '[columns]<br><br>[column size="fourth" last="no"]CONTENT[/column]<br>[column size="fourth" last="no"]CONTENT[/column]<br>[column size="fourth" last="no"]CONTENT[/column]<br>[column size="fourth" last="yes"]CONTENT[/column]<br><br>[/columns]',
    'Mix-column example: fourth-fourth-half'  => '[columns]<br><br>[column size="fourth" last="no"]CONTENT[/column]<br>[column size="fourth" last="no"]CONTENT[/column]<br>[column size="half" last="yes"]CONTENT[/column]<br><br>[/columns]',
    'Mix-column example: fourth-threefourths'  => '[columns]<br><br>[column size="fourth" last="no"]CONTENT[/column]<br>[column size="three-fourths" last="yes"]CONTENT[/column]<br><br>[/columns]',
    'Mix-column example: twothirds-third'  => '[columns]<br><br>[column size="two-thirds" last="no"]CONTENT[/column]<br>[column size="third" last="yes"]CONTENT[/column]<br><br>[/columns]',
    'Graphs'            => '[graphs]<br><br>[graph percentage="10|20|30|40|50|60|70|80|90|100"]CONTENT[/graph]<br>[graph percentage="10|20|30|40|50|60|70|80|90|100"]CONTENT[/graph]<br><br>[/graphs]',
    'Blockquote'        => '[blockquote size="full|half|third|fourth|two-thirds|three-fourths" align="left|right" byline="anonymous"]\x00QUOTE\x00[/blockquote]',
    'Lorem ipsum'        => '[lorem paragraphs="1"]',

    ''  => '',
    '-- HTML MARKUP '   => '',
    'Heading One'       => '<h1>\x00Heading One\x00</h1> &nbsp;',
    'Heading Two'       => '<h2>\x00Heading Two\x00</h2> &nbsp;',
    'Heading Three'     => '<h3>\x00Heading Three\x00</h3> &nbsp;',
    'Heading Four'      => '<h4>\x00Heading Four\x00</h4> &nbsp;',
    'Heading Five'      => '<h5>\x00Heading Five\x00</h5> &nbsp;',
    'Heading Six'       => '<h6>\x00Heading Six\x00</h6> &nbsp;',
    'Bold Text'         => '<strong>\x00Bold Text\x00</strong> &nbsp;',
    'Emphasis'          => '<em>\x00Emphasis\x00</em> &nbsp;',
    'Tabs'              => '<div class="tab-container"><ul class="tab-nav left"><li data-tab="tab1" class="active">Tab 1 name</li><li data-tab="tab2">Tab 2 name</li><li data-tab="tab3">Tab 3 name</li></ul><div class="tab-content-block clearfix"><h4 class="v_nav v_active" data-tab="tab1">Tab 1</h4><div id="tab1" class="tab_content clearfix">Tab 1 content</div><h4 class="v_nav" data-tab="tab2">Tab 2</h4><div id="tab2" class="tab_content">Tab 1 content</div><h4 class="v_nav" data-tab="tab3">Tab 3</h4><div id="tab3" class="tab_content">Tab 1 content</div></div></div> &nbsp;',
    'Code Snippet'      => '<pre>\x00CODE\x00</pre> &nbsp;',
    'Table'             => '<table><thead><tr><th>No#</th><th>Size</th><th>Title</th><th>DOB</th></tr></thead><tbody><tr><td>sell</td><td>sell</td><td>sell</td><td>sell</td></tr><tr><td>sell</td><td>sell</td><td>sell</td><td>sell</td></tr><tr><td>sell</td><td>sell</td><td>sell</td><td>sell</td></tr><tr><td>sell</td><td>sell</td><td>sell</td><td>sell</td></tr></tbody></table> &nbsp;',

);

//sort array alphabetically
//array_multisort($sc_array);

?>

(function() {  
    tinymce.create('tinymce.plugins.canonstyleselect', {  
        init : function(ed, url) {  
        },  
        createControl : function(n, cm) {  
            switch (n) {
                case 'canonstyleselect':
                    var mlb = cm.createListBox('canonstyleselect', {
                        title : 'Shortcodes',
                        onselect : function(v) {

                            var split_value = v.split('\x00');

                            if(tinyMCE.activeEditor.selection.getContent() != ''){
                                tinyMCE.activeEditor.selection.setContent(split_value[0] + tinyMCE.activeEditor.selection.getContent() + split_value[2]);
                            }
                            else{
                                tinyMCE.activeEditor.selection.setContent(v);
                            }
                        }
                    });

                    <?php 
                        foreach($sc_array as $key => $value) {
                        echo "mlb.add('". $key ."', '". $value ."');";                                
                        }
                    ?>

                    return mlb;
            }
            return null;
        },
    });  
    tinymce.PluginManager.add('canonstyleselect', tinymce.plugins.canonstyleselect);  

})();